<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<?php 
	$arrParam = $this->arrParam;

	$this->Item['name'] = Zendvn_Filter_Filter::filterContent($this->Item['name']);
	$title 			= $this->formText('title',$this->Item['title'],array('class'=>'width-300  bg-green2 floatLeft' ));
	$type 			= $this->formText('b_type',$this->Item['type'],array('class'=>'width-300 floatLeft' ));
	$bgColor		= $this->formText('bg_color',$this->Item['bg_color'],array('class'=>'width-300 floatLeft' ));
	$textColor		= $this->formText('text_color',$this->Item['text_color'],array('class'=>'width-300 floatLeft' ));
	$address		= $this->formText('address',$this->Item['address'],array('class'=>'width-300 floatLeft' ));
	$location		= $this->formText('location',$this->Item['location'],array('class'=>'width-300 floatLeft' ));
	$date   		= $this->formText('date',$this->Item['date'],array('class'=>'width-300 floatLeft' ));
	$time   		= $this->formText('time',$this->Item['time'],array('class'=>'width-300 floatLeft' ));
	$fullName  		= $this->formTextarea('full_name',$this->Item['full_name'],array('class'=>'width-400','rows'=>8));

		

	$options 		= array('inactive'=>$this->translate('Inactive'),'active'=>$this->translate('Active'));	
	$status 		= $this->formSelect('status',$this->Item['status'],array('class'=>'width-150'),$options);
	

	$content 	= $this->formTextarea('description',$this->Item['description'],array('class'=>'width-400','rows'=>8));
	
	
	$picture	= $this->formFile('image',array('class'=>'floatLeft' ));
	if($this->arrParam['action'] == 'edit'){
		$config = new Zendvn_Controller_Config(array('module'=>'default',
				'fileConfig'=>'add-event.ini'));
		// Start - Lấy hình ảnh của avatar
		$pictureConfig = $config->getConfig('image');
		$current_picture = '<div id="load-content-picture" class="clr width-150 center">';
		if(!empty($this->Item['image'])){
			$pictureUrl = $pictureConfig['thumbUrl'] . '/' . $this->Item['image'];
			$removeLink = $this->url(array('action'=>'remove-pic','type'=>'image','file'=>$this->Item['image']));
			$current_picture .= '<br>' . $this->cmsImage('image',$pictureUrl,array('width'=>'175px'))
			. '<br><a  class="remove" href="javascript:loadPage(\'div#load-content-picture\',\'' . $removeLink . '\')">remove</a>';
		}
		$current_picture .= $this->formHidden('current_picture',$this->Item['image'])
		. '</div>';
		$picture .=	$current_picture;
	}
	
	

	 if(count($this->errors)>0){	
	 	foreach ($this->errors as $key => $val){	 		
	 		$$key .= $this->cmsError($key,$val);	
	 		$selector = '.form-table #' . $key . '-error';
	 		$options = array('type'=>'error','name'=>'#' .$key);
	 		$formHelp  .= $this->cmsFormHelp($selector, $this->translate($val),null,$options);
	 		
	 	}
	 }
	 $arrRow = array(
					array('label'=>$this->translate('Title'),'input'=>$title),
	 				array('label'=>$this->translate('Picture'),'input'=>$picture),
					array('label'=>$this->translate('Type'),'input'=>$type),
					array('label'=>$this->translate('Background Color'),'input'=>$bgColor),
					array('label'=>$this->translate('Text Color'),'input'=>$textColor),
					array('label'=>$this->translate('Description'),'input'=>$content),
					array('label'=>$this->translate('Address'),'input'=>$address),
					array('label'=>$this->translate('Location'),'input'=>$location),
					array('label'=>$this->translate('Date'),'input'=>$date),
					array('label'=>$this->translate('Time'),'input'=>$time),
					array('label'=>$this->translate('Full Name'),'input'=>$fullName),
					array('label'=>$this->translate('Status'),'input'=>$status),
					);
	$tdForm = $this->partialLoop('row.php',$arrRow);
	
?>
<script type="text/javascript">
	$(document).ready(function() {
		<?php echo $formHelp;?>
	});
</script>
<div id="element-box">
	<div class="m">
		<div class="form-table">
        	<fieldset class="admin-fieldset">
                <legend class="admin-legend"><?php echo $this->translate('Form detail')?></legend>
            	<table width="100%" border="0">
                	<?php echo $tdForm;?>
                </table>
                <div class="clr"></div>
        	</fieldset>  
        </div>
       
        <div class="clr"></div>
	</div>
</div>
<script>
    $(function(){
        $('#date').datepicker({ format: 'mm/dd/yyyy'});

        $('#full_name').tagsInput({width:'auto', defaultText: 'Full name'});

        $('#bg_color,#text_color').ColorPicker({
            onSubmit: function(hsb, hex, rgb, el) {
                $(el).val(hex);
                $(el).ColorPickerHide();
            },
            onBeforeShow: function () {
                $(this).ColorPickerSetColor(this.value);
            }
        })
            .bind('keyup', function(){
                $(this).ColorPickerSetColor(this.value);
            });


    })

</script>